if (SERVER) then
	AddCSLuaFile("shared.lua")
	SWEP.HoldType			= "pistol"
end

if (CLIENT) then
	SWEP.CSMuzzleFlashes    = true
	SWEP.Slot		= 3
	SWEP.SlotPos		= 8
end

SWEP.PrintName	= "Paintball Gun"
	
SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true
SWEP.ViewModel			= "models/Weapons/v_blazer.mdl"
SWEP.WorldModel			= "models/Weapons/w_blazer.mdl"
SWEP.ViewModelFlip		= false

SWEP.Drawammo = true
SWEP.DrawCrosshair = true

SWEP.Weight			= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.Primary.Sound		= Sound("marker/pbfire.wav")
SWEP.Primary.Recoil		= 0.03
SWEP.Primary.Damage		= 1
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone		= 0.01
SWEP.Primary.ClipSize		= 50
SWEP.Primary.Delay		= 0.30
SWEP.Primary.DefaultClip	= 50
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo		= "AR2AltFire"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo		= "none"

SWEP.Other				= true

function SWEP:Reload()
	self.Weapon:DefaultReload(ACT_VM_RELOAD)
end

function SWEP:SecondaryAttack()

end

function SWEP:PrimaryAttack()
	if (!self:CanPrimaryAttack()) then return end
		self.Weapon:EmitSound(Sound("marker/pbfire.wav"))
		self.Weapon:SetNextSecondaryFire(CurTime() + 0.10)
		self.Weapon:SetNextPrimaryFire(CurTime() + 0.10)
		self:ShootEffects()
		self:TakePrimaryAmmo(1)
		if(CLIENT) then return end
		local pb = ents.Create("shot_paint")

		local shotpos = self.Owner:GetShootPos()
		shotpos = shotpos + self.Owner:GetForward() * 5
		shotpos = shotpos + self.Owner:GetRight() * 9
		shotpos = shotpos + self.Owner:GetUp() * -0.5

		pb:SetPos(shotpos)
		pb:SetAngles(self.Owner:EyeAngles())
		pb:SetOwner(self.Owner)
		pb.GetShooter = self.Weapon
		pb:Spawn()

	if SERVER then
		local phys = pb:GetPhysicsObject()
		phys:ApplyForceCenter(self.Owner:GetAimVector() * 7000)
	end
end

function SWEP:ShootEffects()
	self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
	self.Owner:SetAnimation(PLAYER_ATTACK1)
	self.Owner:MuzzleFlash()
end

function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha)
	draw.SimpleText("z", "HL2SelectIcons", x + wide/2, (y + tall*0.2)-10, Color(255, 210, 0, 255), TEXT_ALIGN_CENTER)
end